import { PORT2, PORT1 } from "@/api/config/servicePort";
import http from "@/api";
import { Login, Chat, Game, ReqPage } from "@/api/interface/index";
const prefix = import.meta.env.VITE_TRIAL_YRL
// const prefix = "/api"

/**
 * @name 发送邮箱验证码
 */
export const sendEmailCode = (email: string) => {
    return http.post(`${prefix}/trial/common/sendEmailCode`, { email });
};
/**
 * @name 邮箱登录
 */
export const emailLogin = (email: string, code: string) => {
    return http.post<{ token: string }>(
        `${prefix}/trial/common/emailLogin`, { email, code, }
    );
};
/**
 * @name 获取用户信息
 */
export const getUserInfo = () => {
    return http.get<Game.UserInfo>(`${prefix}/trial/gpt/getUserInfo`, {}, { headers: { noLoading: true }, });
};
/**
 * @name 获取游戏列表
 */
// *
export const getGameList = () => {
    return http.get<Game.GameListData[]>(prefix + `/trial/game/getGameList`)
};
/**
 * @name 获取游戏排行榜
 */
// *
export const getGameRank = (params: Game.GetGameRank) => {
    return http.get<{ list: Game.GameRankData[] } & ReqPage>(prefix + `/trial/game/getGameRank`, params)
};
/**
 * @name 设置分数
 */
// *
export const setScore = (params: Game.SetScore) => {
    return http.post(prefix + `/trial/game/setScore`, params)
};
/**
 * @name 自动消息-新增
 */
// *
export const autoChatAdd = (params: Chat.autoChatAdd) => {
    params.status == undefined && (params.status = 0);
    return http.post(PORT2 + `/api/v1/message/create`, params)
};
/**
 * @name 自动消息-编辑
 */
// *
export const autoChatEdit = (hparams: Chat.autoChatEdit) => {
    const { id, ...params } = hparams;
    return http.put(PORT2 + `/api/v1/message/update/${id}`, params)
};
/**
 * @name 自动消息-删除
 */
// *
export const autoChatDelete = (id: number) => {
    return http.delete(PORT2 + `/api/v1/message/delete/${id}`)
};

/**
 * @name all-登录
 */
// *
export const allLogin = (params: any) => {
    return http.post(PORT1 + `/users/admin/login`, params)
};
/**
 * @name all-用户信息更新
 */
// *
export const allUpdateUser = (params: any, header: any) => {
    return http.post(PORT1 + `/users/admin/update`, params, header)
};
